package com.lsh.kafka;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.listener.MessageListener;

/**
 * @author ：LiuShihao
 * @date ：Created in 2020/8/14 9:29 上午
 * @desc ：
 */
@Slf4j
public class KfkConsumerListener implements MessageListener<String, String>{

    public KfkConsumerListener(){
        System.out.println("KfkConsumerListener加载");
    }

    @Override
    public void onMessage(ConsumerRecord<String, String> data) {
        System.out.println("data.topic():"+data.topic());
        if ("first".equals(data.topic())){
            System.out.println("first主题："+data.value()+"被消费");
        }else if ("hw_data".equals(data.topic())){
            System.out.println("hw_data主题："+data.value()+"被消费");
        }

    }
}
